home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Software Vault: The Gold Collection
/
Software Vault - The Gold Collection (American Databankers) (1993).ISO
/
cdr48
/
pas_0593.zip
/
MOUSEINT.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1993-05-30
|
4KB
|
118 lines
{─ Fido Pascal Conference ────────────────────────────────────────────── PASCAL ─
Msg : 233 of 288
From : Trisdaresa Sumarjoso 1:272/38.0 28 May 93 06:18
To : David Todd
Subj : Tsr's
────────────────────────────────────────────────────────────────────────────────
-=> Quoting David Todd to All <=-
DT>
DT> Help! I'm having troubles making a TSR which involves a mouse. What I
DT> wanted to do was make the TSR pop up when a mouse button was pressed.
DT> But I think it screws up when I get the interrupt vector of the
DT> mouse, and later in the TSR I call Int 33h to read from the mouse. Can
DT> anybody help me out here with a simple example, which would make a
DT> sound if a mouse button is pressed? Thanks in advance...
Hello David...
I've attached my little code to give some example about how to
use Int 33h SubFunction 18h (which install
user-alternate-Subroutine).
Here is the stuff:}
Program TestMouseInt;
Uses
Dos, Crt;
Type
ProcType = Procedure;
Var
Regs : Registers;
Function CheckMouse(Var ButtonNumber: Byte): Boolean;
Begin
Regs.AX := $00;
Intr($33, Regs);
ButtonNumber := Regs.BX; { Total # of Button on the mouse }
CheckMouse := (Regs.AX <> 0); { True if mouse is installed }
End;
Procedure ShowMouse;
Begin
Regs.AX := $01;
Intr($33, Regs);
End;
Procedure HideMouse;
Begin
Regs.AX := $02;
Intr($33, Regs);
End;
{$F+}
Procedure DoSound;
Begin
Sound(220);
Delay(200);
NoSound;
End;
{$F-}
Function SetAltProc( AltProc: ProcType;
CondMask: Word): Integer;
Begin
Regs.AX := $18; { SubFunction $18, Install user proc }
{
The SubFunction $18 is prefered as it's offering a wider range
of condition than SubFunction $0C.
}
Regs.CX := CondMask; { Condition to be met }
Regs.DX := Ofs(AltProc); { Offset of the alternate proc }
Regs.ES := Seg(AltProc); { Segment of the alternate proc }
Intr($33, Regs);
SetAltProc := Regs.AX;
End;
Var
ButtonNumber : Byte;
Result : Integer;
Begin
If CheckMouse(ButtonNumber) Then
Begin
ClrScr;
ShowMouse;
Result := SetAltProc(DoSound, 34); { 34 = Shift + Left
button }
If (Result <> -1) Then
Repeat
WriteLn('Press Shift+left mouse button...');
WriteLn('Press <ENTER> to exit.');
Until (ReadKey = #13)
Else
WriteLn('Unable to install procedure...');
End
Else
WriteLn('Mouse is unavailable...');
End.
The reason I'm using SubFunction 18h here is because with this
SubFunction, you're allowed to used combination of keyboard-keys
(Shift, Ctrl, and Alt) with any mouse button (unfortunately, it
will ONLY work with this combo).
Another reason is with SubFunction 18h, you might be able to
avoid calling Int 33h directly (depending upon what info you
need). Since you're writing a TSR it might be better to use this
method since the driver will pass you some info on the mouse
(Such as AX --> Condition mask.
BX --> Button state.
CX --> Horizontal cursor coor.
DX --> Vertical cursor coor.
SI --> Horizontal mickeys.
DI --> Vertical mickeys.)